package com.fzshang.api.controller;

import cn.hutool.system.OsInfo;
import cn.hutool.system.RuntimeInfo;
import cn.hutool.system.SystemUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzshang.commen.bean.User;
import com.fzshang.commen.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;



import java.io.File;
import java.io.InputStream;
import java.net.URL;
import org.springframework.util.ResourceUtils;


/**
 * @author 冯政尚
 * @data 2019/10/17 15:11
 */
@Controller
@RequestMapping("/index")
public class IndexConteroller extends BaseController {
//         public static  void main(String[] args){
//           System.err.println(SystemUtil.getRuntimeInfo());  ;
//
//        }

    /**
     * @param
     * @return 跳转欢迎页
     */
    @RequestMapping(value = "/productionManagement.html",method = RequestMethod.GET)
    public String productionManagement(Model model){
        //查询通过的商家总数
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("state",2);
        List<User> users = userService.list(queryWrapper);
        model.addAttribute("userCount",users.size());
        return "index/productionManagement";
    }
    @RequestMapping(value = "/statisticsTables.html",method = RequestMethod.GET)
    public String statisticsTables(Model model){
        model.addAttribute("user",getUser());
            return "/index/statisticsTables";
    }



     @RequestMapping(value = "/OSINFO",method = RequestMethod.GET)
     @ResponseBody
    public OsInfo OSINFO(){
        return SystemUtil.getOsInfo();
    }


     @RequestMapping(value = "/MemoryINFO",method = RequestMethod.GET)
     @ResponseBody
    public Map MemoryINFO(){
        RuntimeInfo runtimeInfo= SystemUtil.getRuntimeInfo();
         Map map=new HashMap();
         map.put("max",runtimeInfo.getMaxMemory());
         map.put("total",runtimeInfo.getTotalMemory());
         map.put("free",runtimeInfo.getFreeMemory());
         map.put("usable",runtimeInfo.getUsableMemory());
        return map ;
    }

     @RequestMapping(value = "a.html")
    public String a(){
        return "a";
     }





}




